import 'package:flutter/material.dart';
import 'package:wk_weather/bean/CityInfo.dart';
import 'package:wk_weather/myConfig/weather_type.dart';
import 'package:wk_weather/generated/json/mybean/WeatherModel.dart';
import 'package:wk_weather/views/pages/home/RealTimeTempView.dart';

class RealtimeView extends StatelessWidget {
  final WeatherModelEntity entity;
  final CityModel cityModel;

  const RealtimeView({ Key key, @required this.entity,  this.cityModel }) : super(key: key);

  @override
  Widget build(BuildContext context) {

    var child;
    if (entity != null &&  entity.result != null && entity.result.realtime != null) {

      child = Column(
        mainAxisAlignment: MainAxisAlignment.end,
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // todo 天气温度
          RealTimeTempView(temp: entity.result.realtime.temperature?.toString(), ),
          // 天气 短语
          Container(
            margin: EdgeInsets.only(left: 20),
            child: Row(
              children: [    //
                Text(
                  "${WeatherUtils.convertDesc(entity.result.realtime.skycon)},  ",
                  style: TextStyle(
                      fontSize: 18,
                      color: Colors.white,
                      fontWeight: FontWeight.bold),
                ),
                Text(
                  "${entity.result.forecastKeypoint}",
                  style: TextStyle(
                      fontSize: 15,
                      color: Colors.white,
                      fontWeight: FontWeight.bold),
                ),

              ],
            ),
          ),
          SizedBox(
            height: 40,
          ),
        ],
      );
    }
    return Container(
      // height: realTimeWidgetHeight,
      child: child,
    );
  }
}
